package com.panda.game.xls.action;

import com.panda.game.xls.config.SheetTypeData;
import com.panda.game.xls.config.SheetTypeDataConfig;
import com.panda.game.xls.screen.TabPage1;
import com.panda.game.xls.screen.TabPage2;

import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

public class SheetTypeDataAction extends MyAbstractAction {

    @Override
    protected void beforeAction(ActionEvent e) {

    }

    @Override
    protected void doAction(ActionEvent e) {
        List<SheetTypeData> sheetTypeDataList = new ArrayList();

        Vector vector = TabPage2.tableModel.getDataVector();
        for (int i = 0; i < vector.size(); i++) {
            Vector v = (Vector) vector.get(i);
            if ("".equals(v.get(0).toString()) || "".equals(v.get(1).toString()) || "".equals(v.get(2).toString())) {
                continue;
            }
            SheetTypeData data = new SheetTypeData(v.get(0).toString(), v.get(1).toString(), Integer.parseInt(v.get(2).toString()));
            sheetTypeDataList.add(data);
        }
        SheetTypeDataConfig.setList(sheetTypeDataList);
        SheetTypeDataConfig.setSheetTypeDataList(sheetTypeDataList);
        TabPage1.reflashSheetTypeData();
    }

    @Override
    protected void afterAction(ActionEvent e) {

    }
}
